<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UserMore extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'nationality',
        'address',
        'health',
        'marital',
        'employment_registration',
        'email',
        'qq',
        'idcard_file',
        'height',
        'education_level',
        'graduation_cert',
        'medical_history',
        'political',
        'labor_contract',
        'entry_date',
        'trial_period',
        'handbook_commitment_letter',
        'emergency_contact',
        'emergency_contact_mobile',

        'probationary_salary',
        'basic_year_salary',
        'salary_agreements',
        'subsidies',
        'other_subsidies',
        'rewards',
        'total_salary',


        'previous_unit',
        'previous_unit_user',
        'previous_unit_mobile',
        'resignation_cert',
        'social_security_cert',
        'bank_statement',
        'employment_form',
        'labor_contract',
        'company_policy_agreement',
        'probation_approval_form',
        'employment_registration',

        'resignation_report',
        'out_report',
        'reason_leaving',
        'resign_date',
        'handover_records',
        'resignation_interview',
        'resignation_interview_file',
        'salary_settlement_cert',
    ];

    const POSTONLY = [
       'user_id',
        'nationality',
        'address',
        'health',
        'marital',
        'employment_registration',
        'email',
        'qq',
        'idcard_file',
        'height',
        'education_level',
        'graduation_cert',
        'medical_history',
        'political',
        'labor_contract',
        'entry_date',
        'trial_period',
        'handbook_commitment_letter',
        'emergency_contact',
        'emergency_contact_mobile',

        'probationary_salary',
        'basic_year_salary',
        'salary_agreements',
        'subsidies',
        'other_subsidies',
        'rewards',
        'total_salary',


        'previous_unit',
        'previous_unit_user',
        'previous_unit_mobile',
        'resignation_cert',
        'social_security_cert',
        'bank_statement',
        'employment_form',
        'labor_contract',
        'company_policy_agreement',
        'probation_approval_form',
        'employment_registration',

        'resignation_report',
        'out_report',
        'reason_leaving',
        'resign_date',
        'handover_records',
        'resignation_interview',
        'resignation_interview_file',
        'salary_settlement_cert',
    ];

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function project()
    {
        return $this->hasOne(Project::class,'id','project_id')->select('id','title','status');
    }

    public function user()
    {
        return $this->hasOne(User::class,'id','user_id')->select('id','name','status');
    }
}
